package market.emums;

import market.constant.CommonConstant;

import java.math.BigDecimal;
import java.util.Arrays;

import market.constant.CommonConstant;

/**
 * 水果枚举类
 */
public enum FruitEnum{
    UNKNOWN("未知", "unknown", BigDecimal.ZERO),
    APPLE("苹果", "apple", CommonConstant.APPLE_PRICE),
    STRAWBERRY("草莓", "strawberry", CommonConstant.STRAWBERRY_PRICE),
    MANGO("芒果", "mango", CommonConstant.MANGO_PRICE);
    private final String cnName;
    private final String enName;
    private final BigDecimal price; //金额/斤

    FruitEnum(String cnName, String enName, BigDecimal price){
        this.cnName = cnName;
        this.enName = enName;
        this.price = price;
    }


    public static FruitEnum findByEnName(String value){
        return Arrays.stream(values())
                .filter(fruitEnum -> fruitEnum.getEnName().equals(value))
                .findAny()
                .orElse(UNKNOWN);
    }

    public String getCnName() {
        return cnName;
    }

    public String getEnName() {
        return enName;
    }

    public BigDecimal getPrice() {
        return price;
    }


}
